﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimplePad.Tools
{
    public static class Skin
    {
        private static Renderer rend = new Renderer();

        public static void ApplySkinToForm(Form frm)
        {
            ApplySkinToContainer(frm);
        }

        public static void ApplySkinToContainer(ContainerControl ctl)
        {
            foreach (var c in ctl.Controls)
            {
                if (c.GetType() == typeof(ToolStripContainer))
                {
                    ApplySkinToContainer(c as ToolStripContainer);
                    continue;
                }
                if (c.GetType() == typeof(ToolStripPanel))
                {
                    (c as ToolStripPanel).Renderer = rend;
                    ApplySkinToContainer(c as ToolStripPanel);
                    continue;
                }
                if (c.GetType() == typeof(ContextMenuStrip))
                {
                    (c as ContextMenuStrip).Renderer = rend;
                }
                if (c.GetType() == typeof(MenuStrip))
                {
                    (c as MenuStrip).Renderer = rend;
                }
                if (c.GetType() == typeof(ToolStrip))
                {
                    (c as ToolStrip).Renderer = rend;
                }
                if (c.GetType() == typeof(StatusStrip))
                {
                    (c as StatusStrip).Renderer = rend;
                }
            }
        }
    }
}
